//
//  MyOrderView.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/11.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "MyOrderView.h"
#import "CommonMacro.h"

@interface MyOrderView ()<UITableViewDataSource,UITableViewDelegate>
{
    NSMutableArray *pictureArr,*titleArr,*priceArr,*orderNumArr;
    UIButton *clickButton ;
    UIView *topBgView;
    UILabel *nickNameLabel;
    UIView *addBgBView;
}


@property (nonatomic,strong) UITableView *tableView;
@end

@implementation MyOrderView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
                [self addSubViews];
    }
    return self;
}

#pragma mark 创建子控件
- (void)addSubViews
{
    pictureArr = [NSMutableArray new];
    titleArr = [NSMutableArray new];
    priceArr = [NSMutableArray new];
    orderNumArr = [NSMutableArray new];

    //添加tableView
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT*0.9)];
    [self addSubview:self.tableView];
    self.tableView.delegate =self;
    self.tableView.dataSource = self;
    self.tableView.showsVerticalScrollIndicator = NO;
    //    _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    //1.添加大背景
    UIView *cellBgView = [[UIView alloc] initWithFrame:CGRectMake(10, 5, SCREEN_WIDTH-20, 184)];
    cellBgView.backgroundColor = [UIColor cyanColor];
    cellBgView.layer.cornerRadius = 5;
    cellBgView.clipsToBounds = YES;
    [cell addSubview:cellBgView];
    
    //2.订单号
    UILabel *orderLabel = [[UILabel alloc] initWithFrame:CGRectMake(cellBgView.frame.origin.x, cellBgView.frame.origin.y, cellBgView.frame.size.width, cellBgView.frame.size.height*0.15)];
    orderLabel.text = @"订单号：23u3408y5384t348t";
    orderLabel.textColor = UIColorWithRGBA(253, 241, 240, 1);
    orderLabel.backgroundColor = UIColorWithRGBA(211, 78, 31, 1);
    [cell addSubview:orderLabel];
    
    //3.添加商品图片
    UIImageView *pictureImageView = [[UIImageView alloc] initWithFrame:CGRectMake(orderLabel.frame.origin.x+10, orderLabel.frame.origin.y+orderLabel.frame.size.height+14, cellBgView.frame.size.width*0.35, cellBgView.frame.size.height*0.7)];
    pictureImageView.backgroundColor = [UIColor greenColor];
    [cell addSubview:pictureImageView];
    
    //4.添加详细内容叙述
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(pictureImageView.frame.origin.x+pictureImageView.frame.size.width+3,orderLabel.frame.origin.y+orderLabel.frame.size.height+3 ,cellBgView.frame.size.width*0.56, cellBgView.frame.size.height*0.1)];
    //    titleLabel.backgroundColor = [UIColor redColor];
    titleLabel.text = @"婴儿推车高景观 避震充气轮 婴儿车可躺可坐 BB折叠手推车";
    titleLabel.textColor = UIColorWithRGBA( 131, 127, 127, 1);
    titleLabel.numberOfLines = 0;
    [titleLabel sizeToFit];
    titleLabel.font = [UIFont systemFontOfSize:15];
    [cell addSubview:titleLabel];
    
    //5.添加价钱
    UILabel *priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(titleLabel.frame.origin.x, titleLabel.frame.size.height+titleLabel.frame.origin.y, titleLabel.frame.size.width*0.5, cellBgView.frame.size.height*0.2)];
    //    priceLabel.backgroundColor = [UIColor greenColor];
    priceLabel.text = @"185.0";
    [cell addSubview:priceLabel];
    
    //6.添加颜色 数量
    UILabel *colorLabel = [[UILabel alloc] initWithFrame:CGRectMake(titleLabel.frame.origin.x-10, priceLabel.frame.origin.y+priceLabel.frame.size.height+12,priceLabel.frame.size.width*0.88, priceLabel.frame.size.height*0.3)];
    //    colorLabel.backgroundColor = [UIColor blueColor];
    colorLabel.textColor = UIColorWithRGBA(176, 174, 174, 1);
    colorLabel.text = @"颜色：红色";
    colorLabel.numberOfLines = 0;
    [colorLabel sizeToFit];
    colorLabel.font = [UIFont systemFontOfSize:12];
    [cellBgView addSubview:colorLabel];
    
    UILabel *numLabel = [[UILabel alloc] initWithFrame:CGRectMake(colorLabel.frame.size.width+3+colorLabel.frame.origin.x, colorLabel.frame.origin.y+colorLabel.frame.size.height*0.4, priceLabel.frame.size.width*0.66, priceLabel.frame.size.height*0.2)];
    numLabel.text = @"数量:1";
    numLabel.textColor = UIColorWithRGBA(158, 156, 156, 1);
    numLabel.font = [UIFont systemFontOfSize:12];
    //    numLabel.backgroundColor = [UIColor greenColor];
    [cellBgView addSubview:numLabel];
    
    //7.添加立即付款 或 确认收货按钮
    UIButton *chekButton = [[UIButton alloc] initWithFrame:CGRectMake(cellBgView.frame.size.width-priceLabel.frame.size.width*0.92, priceLabel.frame.origin.y-10, priceLabel.frame.size.width*0.8, priceLabel.frame.size.height)];
    chekButton.backgroundColor = UIColorWithRGBA(247, 122, 77, 1);
    [chekButton setTitle:@"立即付款" forState:UIControlStateNormal];
    chekButton.layer.cornerRadius = 5;
    chekButton.clipsToBounds = YES;
    [chekButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
    [cellBgView addSubview:chekButton];
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
}

@end
